home *** CD-ROM | disk | FTP | other *** search
- #include <ezycom.h>
- #include <ezylib.h>
- #include <stdio.h>
- #include <io.h>
- #include <dos.h>
- #include <dir.h>
- #include <share.h>
-
- int GetSysInfo(FILE *&hSysInfo,SysInfoRecord &SysInfo)
- {
- char SysInfoPath[MAXPATH];
- int Result;
- sprintf(SysInfoPath,"%sSYSINFO.BBS",SystemPath);
- if ((hSysInfo = _fsopen(SysInfoPath,"rb+",SH_DENYNO)) != NULL) {
- int Count = 0, Status;
- while (((Status = lock(fileno(hSysInfo),0L,(long)sizeof(SysInfo))) != 0) &&
- (Count++ <= 15)) {
- sleep(2);
- }
-
- if (Status == 0) {
- int Len = fread(&SysInfo,sizeof(SysInfo),1,hSysInfo);
- if (Len == 1) {
- ftime ftimep;
- date datep;
- getdate(&datep);
- getftime(fileno(hSysInfo),&ftimep);
- if ((datep.da_year != ftimep.ft_year + 1980) ||
- (datep.da_mon != ftimep.ft_month) ||
- (datep.da_day != ftimep.ft_day)) {
- SysInfo.NewUsers = 0;
- SysInfo.NewFiles = 0;
- SysInfo.NewMessages = 0;
- }
- Result = TRUE;
- } else {
- fclose(hSysInfo);
- Result = FALSE;
- }
- } else
- Result = FALSE;
- } else
- Result = FALSE;
- return(Result);
- }
-
- void PutSysInfo(FILE *&hSysInfo,SysInfoRecord &SysInfo)
- {
- int Status = unlock(fileno(hSysInfo),0L,(long)sizeof(SysInfo));
- if (Status == 0) {
- fseek(hSysInfo,SEEK_SET,0);
- fwrite(&SysInfo,sizeof(SysInfo),1,hSysInfo);
- }
- fclose(hSysInfo);
- }
-
-
-